﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Windows.Controls;
using FinPlusAssembler;
using FinPlusInterfaces;

namespace FinPlusCompView
{
    public partial class FinPlusStackPanel : FinPlusControl
    {
        [State(Test = true)]
        public override bool IsValid { get; set; }
        [State(Save = true)]
        public new double Height { get { return base.Height; } set { base.Height = value; } }
        [State(Save = true)]
        public new double Width { get { return base.Width; } set { base.Width = value; } }
        [State(Test = true)]
        public int ChildrenCount { get { return stackPanel.Children.Count; } }

        public override IPods Adapter { get { return base.Children(stackPanel.Children); } }

        //construct
        public FinPlusStackPanel(IFinPlusComp[] controls)
        {
            InitializeComponent();

            foreach(var control in controls)
                stackPanel.Children.Add((UserControl)control);

            IsValid = true;
        }

        //common control interface
        public override void Dock(object control, string dock)
        {
            try
            {
                stackPanel.Children.Add((UserControl)control);
            }
            catch (Exception e)
            {
                IsValid = Level.Warning.Log(Id, Config, e.Message, e);
            }
        }
    }
}
